<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [100, 999, 888];
        // 当前值value , 索引号index , 数组本身array
        var sum = 0;
        arr.forEach(function(value, index, array) {
            console.log('value为' + value + 'index为' + index + '数组本身为' + array);
            // 把数组中元素相加
            sum += value;
        })
        console.log(sum);
    </script>
</body>

</html>